package network.chat;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetSocketAddress;

/**
 * @author mubei
 * @date 2021/12/5
 * @description
 */
public class UDPSend01 {

    public static void main(String[] args) throws Exception {
        DatagramSocket socket = new DatagramSocket(8888);
        //准备数据
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while(true){
            String s = br.readLine();
            byte[] bytes = s.getBytes();
            DatagramPacket packet =new DatagramPacket(bytes,0,bytes.length,new InetSocketAddress("localhost",6666));
            socket.send(packet);
            if(s.equals("bye")){
                break;
            }
        }

        socket.close();

    }
}
